<!-- eslint-disable vue/multi-word-component-names -->
<template>
  <div>
    <el-card class="box-card">
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>资产管理</el-breadcrumb-item>
            <el-breadcrumb-item>资产类型列表</el-breadcrumb-item>
        </el-breadcrumb>
        <el-row :gutter="20">
            <el-col :span="12">
                <el-input placeholder="请输入内容" v-model="search">
                    <el-button slot="append" icon="el-icon-search" ></el-button>
                </el-input>
            </el-col>
        </el-row>
        <el-table :data="dataList" border style="width: 100%">
            <el-table-column type="index"  label="行号" > </el-table-column>
            <el-table-column prop="label" label="名称" > </el-table-column>
            <el-table-column prop="name" label="类型名" > </el-table-column>
            <el-table-column prop="version" label="版本" > </el-table-column>
            <el-table-column  label="操作">
                <template  >
                  <el-tooltip content="分配权限"  effect="light" >
                    <el-button  @click="handleSetPerm(row)" type="info" icon="el-icon-setting" size="mini"></el-button>
                  </el-tooltip>
                  <el-tooltip content="修改"  effect="light" >
                    <el-button   type="info" icon="el-icon-edit" size="mini"></el-button>
                  </el-tooltip>
                  <el-tooltip content="删除"  effect="light" >
                    <el-button  type="danger" icon="el-icon-delete" size="mini"></el-button>
                  </el-tooltip>
                </template>
              </el-table-column>
        </el-table>
        <el-pagination
           @current-change="handleCurrentChange"
           :current-page="pagination.page"
           :page-size="pagination.size"
           layout="total, prev, pager, next, jumper"
           :total="pagination.total">
        </el-pagination>
    </el-card>
</div>
</template>

<script>

export default {
  created() {
    this.getList()
  },
  data() {
    return {
      search: '',
      pagination: {
        total: 0,
        size: 20,
        page: 1
      },
      dataList: []
    }
  },
  methods: {
    resetForm(name) {
      // const name = 'addPerm'
      // console.log('++++++++++++++++++++')
      console.log(name)
      this.$refs[name].resetFields()
    },
    handleCurrentChange(page) {
      this.getList(page)
    },
    async getList(page = 1) {
      if (!page) {
        page = 1
      }
      const { data: response } = await this.$http.get('cmdb/citypes/', {
        params: {
          page
        }
      })
      if (response.code) {
        return this.$message.error(response.message)
      }
      this.dataList = response.results
      this.pagination = response.pagination
    }
  }
}
</script>

<style>

</style>